<?php	
	// Interface function	
	function oh_module_mysql($tokens) {
		global $oh_object_mysql;
		return $oh_object_mysql;	
	} 

	// Option file required
	if (function_exists("mysql_connect")) {
		require_once(dirname(__FILE__)."/ezsql/shared/ez_sql_core.php");
		require_once(dirname(__FILE__)."/ezsql/mysql/ez_sql_mysql.php");
	} else {class ezSQL_mysql {}}
	
	// Main class of module
	class oh_class_mysql extends ezSQL_mysql {		
		public $ready;
		function oh_class_mysql() {
			if (function_exists("mysql_connect")) {
				$this->ezSQL_mysql(
					oh("config.db.username"),
					oh("config.db.password"),
					oh("config.db.name"),
					oh("config.db.host")
				);
				$e = $this->query("SHOW DATABASES");
				if ($e>0) {
					$this->ready = true;
				} else {
					$this->ready = false;
				}
			} else {
				$this->ready = false;
			}
		}
		function is_ready() {
			return $this->ready;
		}
		function error() {
			$error = mysql_error();
			if (strlen($error)>0) {
				echo oh_debug_div_open();
					echo $error;
					echo oh_debug_small_open();
					echo oh_debug_at("error");			
					echo oh_debug_small_close();
					echo oh_debug_pre_open();			
					var_dump( ($this->last_query) );
					echo oh_debug_pre_close();
				echo oh_debug_div_close();
			}
		}
	}
	
	// Main object of module
	global $oh_object_mysql;
	$oh_object_mysql = new oh_class_mysql();
?>
